package com.zhentao.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhentao.model.banner.pojo.AdBanner;
import com.zhentao.model.common.dtos.PageResponseResult;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pay.dto.PayDto;
import com.zhentao.model.pay.pojo.AdMembershipCard;
import com.zhentao.model.pay.vo.PayVo;
import com.zhentao.service.AdMembershipCardService;
import com.zhentao.mapper.AdMembershipCardMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
* @author 许文倩
* @description 针对表【ad_membership_card】的数据库操作Service实现
* @createDate 2024-07-09 11:29:01
*/
@Service
public class AdMembershipCardServiceImpl extends ServiceImpl<AdMembershipCardMapper, AdMembershipCard>
    implements AdMembershipCardService{
    @Resource
    AdMembershipCardMapper adMembershipCardMapper;

    @Override
    public PageInfo<AdMembershipCard> getList(PayDto dto) {
        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
        List<AdMembershipCard> adMembershipCards = adMembershipCardMapper.selectList(null);
        PageInfo<AdMembershipCard> adMembershipCardPageInfo=new PageInfo<>(adMembershipCards);
        return adMembershipCardPageInfo;
    }

    @Override
    public ResponseResult add(AdMembershipCard adMembershipCard) {
        adMembershipCard.setCreatedTime(new Date());
        adMembershipCardMapper.insert(adMembershipCard);
        return ResponseResult.okResult("添加成功");
    }

    @Override
    public ResponseResult updateCard(AdMembershipCard adMembershipCard) {
        adMembershipCard.setUpdatedTime(new Date());
        adMembershipCardMapper.updateById(adMembershipCard);
        return ResponseResult.okResult("修改成功");
    }

    @Override
    public ResponseResult getTypeList() {
        List<AdMembershipCard> cardTypes=adMembershipCardMapper.typeList();
        return ResponseResult.okResult(cardTypes);
    }
}




